/*
 * NodeSource.cpp
 *
 *  Created on: 10/11/2011
 *      Author: godinho
 */

#include "NodeSource.h"
#include "SimulationNode.h"
#include "NodeInput.h"
#include "utils.h"

NodeSource::NodeSource(SimulationNode* node, SimulationNode* target, float arrivalRate)
						: mNode(node), mTarget(target), mArrivalRate(arrivalRate) {
}

NodeSource::~NodeSource() {
}

int NodeSource::generate() {
	NodeInput* input = mTarget->getNodeInput(mNode);

	int amount = poison(mArrivalRate);
	input->addCarsOnTrip(amount);

	mLastGeneratedAmount = amount;

	return amount;
}

SimulationNode* NodeSource::getNode() {
	return mNode;
}

SimulationNode* NodeSource::getTarget() {
	return mTarget;
}

int NodeSource::getLastGeneratedAmount() {
	return mLastGeneratedAmount;
}

float NodeSource::getArrivalRate() {
	return mArrivalRate;
}
